﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows;
using System.Collections;

namespace UBConDemo.Models
{
    public class UbConItemModel:INotifyPropertyChanged
    {
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------
        #region Constructors

        #endregion

        //------------------------------------------------------
        //
        //  Properties
        //
        //------------------------------------------------------
        #region Properties

        /// <summary>
        /// Gets or sets a boolean value indicating whether current view is shown in a new window.S
        /// </summary>
        public bool ShowInAnotherWindow 
        {
            get 
            {
                return _showInAnotherWindow;
            }
            set 
            {
                _showInAnotherWindow = value;
            }
        }

        /// <summary>
        /// Gets or sets a boolean value indicating whether associated container is enabled or not.
        /// </summary>
        public bool IsEnabled 
        {
            get 
            {
                return _isEnabled;
            }
            set 
            {
                _shouldRaiseEvent = _isEnabled != value;
                _isEnabled = value;
                if (_shouldRaiseEvent) 
                {
                    OnPropertyChanged("IsEnabled");
                }
            }
        }
        
        /// <summary>
        /// Gets or sets item's title.
        /// </summary>
        public string Title 
        {
            get 
            {
                return _title;
            }
            set 
            {
                _shouldRaiseEvent = string.Compare(_title, value) != 0;
                _title = value;
                if (_shouldRaiseEvent)
                {
                    OnPropertyChanged("Title");
                }
            }
        }

        /// <summary>
        /// Gets or sets item's image source.
        /// </summary>
        public string Image 
        {
            get 
            {
                return _image;
            }
            set 
            {
                _shouldRaiseEvent = string.Compare(_image, value) != 0;
                _image = value;
                if (_shouldRaiseEvent) 
                {
                    OnPropertyChanged("Image");
                }
            }
        }

        /// <summary>
        /// Gets or sets a boolean value that indicates whether item simply represents category name.
        /// </summary>
        public bool IsCategoryNameItem 
        {
            get 
            {
                return _isCategoryNameItem;
            }
            set 
            {
                _shouldRaiseEvent = _isCategoryNameItem != value;
                _isCategoryNameItem = value;
                if (_shouldRaiseEvent) 
                {
                    OnPropertyChanged("IsCategoryNameItem");
                }
            }
        }

        /// <summary>
        /// Gets or sets full path of related view.
        /// </summary>
        public string View 
        {
            get 
            {
                return _view;
            }
            set 
            {
                _shouldRaiseEvent = string.Compare(_view, value)!=0;
                _view = value;
                if (_shouldRaiseEvent) 
                {
                    OnPropertyChanged("View");
                }
            }
        }

        /// <summary>
        /// Gets or sets view's id.
        /// </summary>
        public string ViewType 
        {
            get 
            {
                return _viewType;
            }
            set 
            {
                _viewType = value;
            }
        }
        #endregion

        //------------------------------------------------------
        //
        //  Overrides
        //
        //------------------------------------------------------
        #region Overrides
        #endregion

        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------
        #region Public Methods
        #endregion

        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------
        #region Internal Methods
        #endregion

        //------------------------------------------------------
        //
        //  Private Methods
        //
        //------------------------------------------------------
        #region Private Methods

        /// <summary>
        /// Raises PropertyChanged event with specified propety.
        /// </summary>
        private void OnPropertyChanged(string propertyName) 
        {
            if (PropertyChanged != null) 
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion

        //------------------------------------------------------
        //
        //  Event Handlers
        //
        //------------------------------------------------------
        #region Event Handlers
        #endregion

        //------------------------------------------------------
        //
        //  Fields
        //
        //-----------------------------------------------------
        #region Fields

        private string _title, _image;
        private bool _shouldRaiseEvent = false, _isCategoryNameItem = false, _isEnabled = true, _showInAnotherWindow = false;
        private string _view = null, _viewType;

        #endregion

        //------------------------------------------------------
        //
        //  Events
        //
        //-----------------------------------------------------
        #region Events

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

    }
}
